import http from '@/utils/http'

const BASE_URL = '/testing/stressCaseModule'

export interface StressCaseModuleResp {
  id: string
  projectId: string
  name: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface StressCaseModuleDetailResp {
  id: string
  projectId: string
  name: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface StressCaseModuleQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface StressCaseModulePageQuery extends StressCaseModuleQuery, PageQuery {}

/** @desc 查询压测用例模块列表 */
export function listStressCaseModule(query: StressCaseModulePageQuery) {
  return http.get<PageRes<StressCaseModuleResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询压测用例模块详情 */
export function getStressCaseModule(id: string) {
  return http.get<StressCaseModuleDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增压测用例模块 */
export function addStressCaseModule(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改压测用例模块 */
export function updateStressCaseModule(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除压测用例模块 */
export function deleteStressCaseModule(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出压测用例模块 */
export function exportStressCaseModule(query: StressCaseModuleQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
